<?php
/**
 * @var string $namespace
 * @var string $version
 * @var string $prefix
 * @var string $middleware
 */
$api = app(Dingo\Api\Routing\Router::class);

$api->version($version, function (Dingo\Api\Routing\Router $api) use ($namespace, $prefix, $middleware) {
    $api->group(['namespace' => $namespace, 'prefix' => $prefix, 'middleware' => $middleware], function ($api) {
    
        $api->group(['prefix' => 'power'], function ($api) {
            //后台页面列表
            /** @var \Xy\Rbac\Controllers\RbacPowerPageController */
            $api->get('/page', 'RbacPowerPageController@index');
            $api->post('', 'RbacPowerPageController@store');
            $api->put('/{id}', 'RbacPowerPageController@update')->where('id', '[0-9]+');
            $api->delete('/{id}', 'RbacPowerPageController@destroy')->where('id', '[0-9]+');
            $api->get('/user-permission', 'RbacPowerPageController@userPermission');
        });
    
        $api->group(['prefix' => 'role'], function ($api) {
            /** @var \Xy\Rbac\Controllers\RbacRoleController */
            $api->post('/page', 'RbacRoleController@getPage');
    
            $api->get('', 'RbacRoleController@index');
            $api->post('', 'RbacRoleController@store');
            $api->put('/{id}', 'RbacRoleController@update')->where('id', '[0-9]+');
            $api->put('/{id}/assign-role-power-page', 'RbacRoleController@assignRolePowerPage')->where('id', '[0-9]+');
            $api->delete('/{id}', 'RbacRoleController@destroy')->where('id', '[0-9]+');
        });
    
        $api->group(['prefix' => 'user'], function ($api) {
            /** @var \Xy\Rbac\Controllers\RbacUserController */
            $api->post('/page', 'RbacUserController@getPage');
            $api->get('/{id}/role-ids', 'RbacUserController@getUserRoleIdList');
            $api->put('/{id}/role', 'RbacUserController@assignRole');
        });
    });
});
